
# 删除整个文件夹中关于node_modules的文件
# -*- coding: utf-8 -*-
import os
import shutil
import time

root_dir = r'D:\\Code'
root_now = ['pim-html', 'mes-html', 'mes-data-sync']
file_result = []
for dir in os.listdir(root_dir):
    child = os.path.join(root_dir, dir)
    if os.path.isdir(child):
        for f1 in os.listdir(child):
            if f1.endswith("node_modules"):
                file_result.append(os.path.join(child, f1))

# print(file_result)
file_filter = []
for item in file_result:
    isContain = False
    for itemString in root_now:
      if itemString in item:
          isContain = True
          break
    if isContain == False:
      file_filter.append(item)
print(file_filter)

for filePath in file_result:
  if os.path.isdir(filePath):
    print('正在删除' + filePath)
    shutil.rmtree(filePath)


